home *** CD-ROM | disk | FTP | other *** search
- ## -*-Tcl-*-
- # ==========================================================================
- # Help files for Alpha
- #
- # FILE: "LaTeX Help.tcl"
- # created: 10/17/00 {02:18:43 pm}
- # last update: 11/30/00 {07:49:20 pm}
- # Description:
- #
- # Script to view the local LaTeX .html manual, either in one's web
- # browser or using Alpha's parser. Additional options include opening,
- # processing, or viewing the latex_<manual>.ext files.
- #
- # Author: Craig Barton Upright
- # E-mail: <cupright@princeton.edu>
- # mail: Princeton University, Department of Sociology
- # Princeton, New Jersey 08544
- # www: <http://www.princeton.edu/~cupright>
- #
- # ==========================================================================
- ##
-
- catch {unset option}
-
- set helpDir [file join $HOME "LaTeX Docs"]
- set helpIntro [file join $HOME Help "LaTeX Help"]
-
- # Is the "LaTeX manual" properly installed?
-
- if {![file isdirectory $helpDir]} {
- if {[file isfile $helpIntro]} {
- help::openDirect $helpIntro
- } else {
- alertnote "The LaTeX Help file documents are not properly installed."
- }
- unset helpDir helpIntro
- return
- }
-
- # If "helpMenuOptions" is 0, then the user wants all of possible options.
- # If "helpMenuOptions" is 1, then the user wants to view the html manual.
- # If "helpMenuOptions" is 2, then the user wants to view a pdf file if
- # there is one available.
-
- if {$helpMenuOptions == 0} {
- set options [list \
- "Open \"LaTeX Help\" introduction" \
- "View .html version of manual" \
- ]
- foreach f {guide menus bindings} {
- # Open in TeX mode options.
- if {[file exists [file join $helpDir latex_${f}.tex]]} {
- lappend options "Open \"latex_${f}.tex\" file in TeX mode"
- }
- }
- foreach f {guide menus bindings} {
- # TeX the file options.
- if {[file exists [file join $helpDir latex_${f}.tex]]} {
- lappend options "TeX \"latex_${f}.tex\" file"
- }
- }
- foreach f {guide menus bindings} {
- # PdfTeX the file options.
- if {[file exists [file join $helpDir latex_${f}.tex]]} {
- lappend options "PdfTeX \"latex_${f}.tex\" file"
- }
- }
- foreach f {guide menus bindings} {
- # View dvi, ps, pdf options.
- if {[file exists [file join $helpDir latex_${f}.dvi]]} {
- lappend options "View \"latex_${f}.dvi\" file"
- }
- if {[file exists [file join $helpDir latex_${f}.ps]]} {
- lappend options "View \"latex_${f}.ps\" file"
- }
- if {[file exists [file join $helpDir latex_${f}.pdf]]} {
- lappend options "View \"latex_${f}.pdf\" file"
- }
- }
- foreach f {guide menus bindings} {
- # Print options.
- if {[file exists [file join $helpDir latex_${f}.dvi]]} {
- lappend options "Print \"latex_${f}.dvi\" file"
- }
- if {[file exists [file join $helpDir latex_${f}.ps]]} {
- lappend options "Print \"latex_${f}.ps\" file"
- }
- }
- foreach f {guide menus bindings} {
- # Dvips options.
- if {[file exists [file join $helpDir latex_${f}.dvi]]} {
- lappend options "Dvips \"latex_${f}.dvi\" file"
- }
- }
- foreach f {guide menus bindings} {
- # Dvipdf options.
- if {[file exists [file join $helpDir latex_${f}.dvi]]} {
- lappend options "Dvipdf \"latex_${f}.dvi\" file"
- }
- }
- foreach f {guide menus bindings} {
- # Distill options.
- if {[file exists [file join $helpDir latex_${f}.ps]]} {
- lappend options "Distill \"latex_${f}.ps\" file"
- }
- }
- lappend options "(Set WWW preferences to avoid this dialog …)"
- } elseif {$helpMenuOptions == 1} {
- if {[file exists [file join $helpDir docs latex_guide index.html]]} {
- # The user wants to view the .html version of the manual.
- set option "View .html version of manual"
- } elseif {![catch {glob -dir [file join $f3] *.pdf} files]} {
- # The .html version doesn't exist, and the user wants to view an
- # existing .pdf file.
- foreach f $files {
- # There are multiple .pdf files to view.
- lappend options "View \"[file tail $f]" file"
- }
- if {[llength $options] == 1} {
- # There's only one .pdf file to view.
- set option [lindex $options 0]
- }
- }
- } elseif {$helpMenuOptions == 2} {
- if {![catch {glob -dir [file join $f3] *.pdf} files]} {
- # The user wants to view an existing .pdf file.
- foreach f $files {
- lappend options "View \"[file tail $f]" file"
- }
- if {[llength $options] == 1} {
- # There's only one .pdf file to view.
- set option [lindex $options 0]
- }
- } elseif {[file exists [file join $helpDir docs latex_guide index.html]]} {
- # There are no .pdf versions to view, and the user wants to view
- # the existing .html file.
- set option "View .html version of manual"
- }
- }
-
- if {![info exists option]} {
- # We still have options.
- set option [listpick \
- -p "LaTeX manual options …" \
- -L "View .html version of manual" $options]
- }
-
- # Take care of some easy options first, then deal with the processing /
- # viewing options. Processing relies on some procs from "latexComm.tcl",
- # which will be loaded if necessary.
-
- if {$option == "(Set WWW preferences to avoid this dialog …)"} {
- dialog::preferences preferences "WWW"
- helpMenu "LaTeX Help"
- } elseif {$option == "Open \"LaTeX Help\" introduction"} {
- help::openDirect $helpIntro
- } elseif {$option == "View .html version of manual"} {
- help::openDirect [file join $helpDir docs latex_guide index.html]
- } elseif {[regexp "^(Open \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Open the .tex file in TeX mode.
- edit -r -c [file join $helpDir $filename]
- } elseif {[regexp "^(TeX \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Typeset the file.
- dummyTeX
- alertnote "Be sure to process this file 3 times !!"
- typesetFile [file join $helpDir $filename]
- } elseif {[regexp "^(PdfTeX \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Typeset the file using pdfLaTeX.
- dummyTeX
- alertnote "Be sure to process this file 3 times !!"
- pdflatexTEXFile [file join $helpDir $filename]
- } elseif {[regexp "^(View \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # View the file using the apps defined by TeX mode.
- dummyTeX
- switch -- [file extension $filename] {
- ".dvi" {
- viewDVIFile [file join $helpDir $filename]
- }
- ".ps" {
- viewPSFile [file join $helpDir $filename]
- }
- ".pdf" {
- viewPDFFile [file join $helpDir $filename]
- }
- }
- } elseif {[regexp "^(Print \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # View the file using the apps defined by TeX mode.
- dummyTeX
- switch -- [file extension $filename] {
- ".dvi" {
- printDVIFile [file join $helpDir $filename]
- }
- ".ps" {
- printPSFile [file join $helpDir $filename]
- }
- }
- } elseif {[regexp "^(Dvips \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Dvips the .dvi file.
- dummyTeX
- evalTeXScript dvips {DVI-to-PS filter} [file join $helpDir $filename]
- } elseif {[regexp "^(Dvipdf \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Dvipdf the .dvi file.
- dummyTeX
- evalTeXScript dvipdf {DVI-to-PDF filter} [file join $helpDir $filename]
- } elseif {[regexp "^(Distill \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
- # Distill the .ps file
- dummyTeX
- distillPSFile [file join $helpDir $filename]
- }
-
- unset helpDir helpIntro option
- catch {
- unset options
- unset match dummy filename
- }
-
-